<?php
/**
 * Created by PhpStorm.
 * User: dumbledore
 * Date: 2018/3/15
 * Time: 下午4:12
 */
?>

<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>首页-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url();?>"/>
    <link rel="shortcut icon" href="public/images/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/index.css"/>
    <link type="text/css" rel="stylesheet" href="public/css/owl.carousel.css">
    <link type="text/css" rel="stylesheet" href="public/css/owl.theme.css">

    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<body>
    <input type="text" name="username" id="username">
    <input type="password" name="password" id="password">
<button onclick="login()">确认</button>
</body>

<?php $this->load->view('common/bottom'); ?>
</html>

<script>

    // 登录
    function login() {
        // 商城登录接口，若登录成功返回shop_user_id，失败返回错误信息msg
        var login_url = 'test/login_api';
        var username = $("#username").val();
        var password = $("#password").val();
        $.ajax({
            type: "get",
            dataType: "jsonp",
            url: webUrl + login_url,
            data: {'username':username,'password':password},
            jsonp: 'callback',
            async: false,
            success: function (data) {
                console.log(data)
                if(data.code == 200)
                {
                    var shop_customer_id = data.shop_user_id;
                    $.ajax({
                        type: "POST",
                        url: "login/login",
                        data: {'shop_customer_id':shop_customer_id},
                        dataType: "json",
                        success: function (data) {
                            if(data.code == 0)
                            {
                                layer.alert('登录成功');
                                window.location.href = 'index';
                            } else {
                                layer.alert(data.msg);
                            }

                        },
                        error:function(XMLHttpRequest, textStatus, errorThrown){
                            layer.alert('someting is wrong')
                        }
                    });
                }
            }
        });

    }
</script>
